var _n36;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $GameEventType = require("GameEventType");
var $1$userService = require("userService");
var c = cc__importDefault($1$userService);
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var $1$EventManager = require("EventManager");
var u = cc__importDefault($1$EventManager);
var $1$yyComponent = require("yyComponent");
var p = cc__importDefault($1$yyComponent);
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
cc__decorator.property;
var def_Scene = function (t) {
  function _ctor() {
    // 使用 apply 方法调用 t，或者使用当前上下文
    var instance = null !== t && t.apply(this, arguments) || this;

    // 初始化实例属性
    instance.xiayiguanBtn = null; // 下一个关卡按钮
    instance.daAn = false; // 答案状态
    instance.tiShi = false; // 提示状态

    return instance; // 返回实例
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () { };
  _ctor.prototype.showVad = function (t) {
    // 检查当前平台是否为 VIVO 游戏
    if (cc.sys.platform === cc.sys.VIVO_GAME) {
      var adPosIds = ["0afa984540e144498b45b47874e1785d", "18978b00f31d4264a3a12be45ede2028"];
      console.log("进入");

      // 设置定时任务
      setTimeout(function () {
        // 检查并创建自定义广告
        if (window.qg && window.qg.createCustomAd) {
          var randomPosId = adPosIds[Math.floor(Math.random() * adPosIds.length)]; // 随机选择一个广告位置 ID

          var ad = window.qg.createCustomAd({
            posId: randomPosId,
            style: {
              top: 200 // 广告顶部位置
            }
          });

          console.log("加载1");
          ad.show(); // 显示广告
          console.log("show");
        }
      }, 1000 * (t || 1)); // 延迟执行，默认延迟 1 秒
    }
  };
  _ctor.prototype.saveData = function () {
    // 获取游戏关卡数据
    var gameLevelData = $zqcc_OverallSystem.sers().userSrv.getGameLevelData();
    $zqcc_OverallSystem.sers().userSrv.getLevel();
    $zqcc_OverallSystem.sers().userSrv.getGameId();
    var guanqiaID = $zqcc_OverallSystem.sers().userSrv.getGuanqiaID();

    // 更新通过的关卡信息
    if (c.default.guanqia[+guanqiaID]) {
      gameLevelData.pass.push({
        level: c.default.guanqia[+guanqiaID].level,
        gameId: c.default.guanqia[+guanqiaID].gameId
      });
    }

    // 更新锁定的关卡信息
    if (c.default.guanqia[+guanqiaID + 1]) {
      gameLevelData.lock.push({
        level: c.default.guanqia[+guanqiaID + 1].level,
        gameId: c.default.guanqia[+guanqiaID + 1].gameId
      });
    } else {
      // 如果没有下一关卡，隐藏下一个关卡按钮
      this.xiayiguanBtn.active = false;
    }

    // 保存更新后的关卡数据
    $zqcc_OverallSystem.sers().userSrv.setGameLevelData(gameLevelData);
    u.default.emit($GameEventType.EventType.DirectorEvent.updataLevelList);
    Date.now();

    // 检查并更新通过关卡日期
    var lastPassDate = $zqcc_OverallSystem.sers().localStorageSrv.get(c.default.passlevelDate);
    if (!(lastPassDate != null && lastPassDate !== "")) {
      $zqcc_OverallSystem.sers().localStorageSrv.set(c.default.passlevelDate, Date.now());
      $zqcc_OverallSystem.sers().userSrv.setpassNumber(0);
    }

    // 更新通过关卡的数量
    var passNumber = $zqcc_OverallSystem.sers().userSrv.getpassNumber();
    passNumber++;
    $zqcc_OverallSystem.sers().userSrv.setpassNumber(passNumber);

    // 进行快捷方式检查
    if (passNumber === 3) {
      var context = this;
      if (window.tt && window.tt.checkShortcut) {
        window.tt.checkShortcut({
          success(response) {
            cc.log("检查快捷方式", response.status);
            var status = response.status;

            // 获取系统信息并检查应用名
            window.tt.getSystemInfo({
              success(sysInfo) {
                cc.log("appName:" + sysInfo.appName);
                // 根据应用名显示页面
                if (["Tt_lite", "Toutiao", "xigua"].includes(sysInfo.appName) || status.exist) {
                  // 已经存在快捷方式，不执行其他操作
                  return;
                }
                $zqcc_OverallSystem.sers().uiSrv.showtianjiazhuomianPage();
              },
              fail() {
                cc.log("getSystemInfo 调用失败");
              }
            });
          },
          fail(err) {
            cc.log("检查快捷方式失败", err.errMsg);
            context.emit($GameEventType.EventType.DirectorEvent.showCheck);
          }
        });
      }
    }
  };
  return cc__decorate([ccp_ccclass], _ctor);
}(p.default);
exports.default = def_Scene;